package drawing;

import math.Point3f;
import math.Vector3f;

public class Camera {

	private Point3f position;
	private Vector3f direction;
	private Vector3f up;
	private float fovy;
	private String name;
	
	public Camera(Point3f position, Vector3f direction, Vector3f up,
			float fovy, String name){
		this.position = position;
		this.direction = direction;
		this.up = up;
		this.fovy = fovy;
		this.name = name;
	}
	
	public Point3f getOrigin(){
		return this.position;
	}
	
	public Vector3f[] getUVW(){
		Vector3f[] result = new Vector3f[3];
		
		float x,y,z,normal;
		
		//calculating w
		normal = this.direction.length();
		x = (this.direction.x*(-1))/normal;
		y = (this.direction.y*(-1))/normal;
		z = (this.direction.z*(-1))/normal;
		result[2] = new Vector3f(x,y,z);
		
		//calculating u
		Vector3f temp = this.up.crossProduct(result[2]);
		normal = temp.length();
		x = temp.x/normal;
		y = temp.y/normal;
		z = temp.z/normal;
		result[0] = new Vector3f(x, y, z);
		
		//calculating v
		result[1] = result[2].crossProduct(result[0]);
		
		return result;
	}
	
	public String getName(){
		return this.name;
	}
	
	public float getFovy(){
		return this.fovy;
	}
	
	public Vector3f getDirection(){
		return this.direction;
	}
}
